trigger CannotDeleteRoutingPlanBeforeThisMonth on RoutingPlan__c (before delete)
{
    Profile prf = [Select p.Name, p.Id From Profile p where Name='System Administrator' or Name='系统管理员' LIMIT 1 ];
    if (prf.Id != UserInfo.getProfileId())
    {
    	Date currDate = System.today();
    	User u=[select Title__c from User where Id=:UserInfo.getUserId()];
	    if(u.Title__c=='Area/District Sales Manager' || u.Title__c=='Sales Supervisor')
	    {
	    	
	        for(RoutingPlan__c plan : trigger.old)
	        {
	            if(plan.StartDateTime__c < currDate)
	            {
	                plan.addError('请勿删除今天以前的拜访计划！');
	            }
	        }
	    }
    }
}